<extend name="Extends/base"/>
<block name="title">徒弟完成的任务</block>
<block name="css">
</block>
<block name="body_style">class="bgc-fff"</block>
<block name="body">
    <div class="c-main">
        <div class="mx-cont">
            <ul class="mx-cont-list c-hide"></ul>
            <a href="javascript:;" class="mx-more" style="display: none">点击查看更多</a>
            <div class="no-data">
                <div class="no-dataimg">
                    <img src="__APPS__/images/nodata.png">
                </div>
                <p class="on-datamsg"></p>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__APPS__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript">
        var currPage = 1;
        var userId = "{$userId}";

        $(function () {
            getRecommerTaskList(1);
        });

        $('.c-main').on('click', '.mx-more', function () {
            currPage += 1;
            getRecommerTaskList(currPage);
        });

        //获取用户列表
        function getRecommerTaskList(page, callback, loading) {
            if (typeof callback != "function") {
                callback = emptyFunc;
            }
            doGetRecommerTaskList(page, userId, function (res) {
                if (res.Code != 10000) {
                    $('.mx-cont-list，.mx-more').hide();
                    showNoData(res.Message);
                    callback(res);
                    return false;
                }
                hideNoData();
                var data = res.Result;
                var html = data.html;
                var hasNext = data.hasNext;
                if (page == 1) {
                    $('.mx-cont-list').html("");
                }
                $('.mx-cont-list').append(html).show();
                if (hasNext) {
                    $('.mx-more').show();
                } else {
                    $('.mx-more').hide();
                }
                callback(res);
            }, loading);
        }

        /**
         * 显示空数据
         * @param msg
         */
        function showNoData(msg) {
            msg = msg ? msg : "";
            $('.no-data').show().find('.on-datamsg').html(msg);
        }

        /**
         * 隐藏空数据
         */
        function hideNoData() {
            $('.no-data').hide().find('.on-datamsg').html("");
        }

    </script>
</block>